/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controlador;

import Facade.MaquinariaFacade;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import vista.BitacoraMaquinaBean;

/**
 *
 * @author Jorge
 */
public class BitacoraMaquinariaAction extends org.apache.struts.action.Action {
    
    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    private final static String VOLVER = "volver";
    
    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        if(isCancelled(request))
        {
            return mapping.findForward(VOLVER);
        }

        Vector bitacora,maquinas;
        String maquina = ((BitacoraMaquinaBean)form).getMaquina();
        MaquinariaFacade fcd = new MaquinariaFacade();
        maquinas = fcd.cargarNomenclaturas();
        bitacora = fcd.BitacoraMaquina(maquina);
        request.setAttribute("listaMaquinarias", maquinas);
        request.setAttribute("bitacoraMaquina",bitacora);

        return mapping.findForward(SUCCESS);
    }
}
